<template>
  <div class="home">
    <!-- 头部 -->
      <div class="top">
        <van-sticky>
          <!-- <van-button type="primary"> -->
              <div class="top1">
                  <div class="left">
                  <i class="el-icon-location-outline"></i>
                    <span>圆融时代广场（久...▼</span>
                  </div>
                <div class="right">
                  <i class="el-icon-search"></i>
                  <input type="text" placeholder="请输入商品名称">
                </div>
                </div>
          <!-- </van-button> -->
        </van-sticky>
        
      <div class="middle">
          <van-swipe class="my-swipe" 
          :autoplay="3000" 
          indicator-color="white">
            <van-swipe-item v-for="item in bannerList" :key="item.id">
              <img :src="item.icon_url" alt="">
            </van-swipe-item>
          </van-swipe>
        </div>
      </div>

    <!-- 列表 -->
      <div class="home_list">
          <ul v-for="item in listText" :key="item.id">
            <li>
              <img :src='item.icon_url' alt="">
              <p class="lis">{{item.name}}</p>
            </li>
          </ul>
      </div>

    <!-- 加入会员 -->
      <div class="vip">
        <img src="../../assets/logo1.jpg" alt="">
        <span style="margin-right:1rem">加入会员·每年预计节省806元</span>
        <span>5折开卡></span>
      </div>

    <!-- 限时抢购 -->
      <div class="timeShop">
        <div class="shop-top">
          <span class="acive-icon"></span>
          <h6>限时抢购</h6>
          <p class="timeout">
            <van-count-down :time="time">
              <template #default="timeData" >
                <span style="background:#000" class="block">{{ timeData.hours }}</span>
                <span  class="colon">:</span>
                <span style="background:#000" class="block">{{ timeData.minutes }}</span>
                <span class="colon">:</span>
                <span style="background:#000" class="block">{{ timeData.seconds }}</span>
              </template>
            </van-count-down>
          </p>
          <span class="more">更多</span>
        </div>
        <div class="shop-text">
          <home-text @shoparr="shoparr"></home-text>
        </div>
      </div>

    <!-- 商品列表 -->
      <div class="listShop">
        <home-shop-text></home-shop-text>
      </div>
  </div>
</template>

<script>
//限时抢购组件：
import HomeText from "@/components/HomeText.vue";
//商品全部列表：
import HomeShopText from "@/components/HomeShopText.vue"

export default {
    name:"HomesView",
    components:{
      HomeText,
      HomeShopText
    },
      data() {
      return { 
        //列表名称：
        listText:[],
        //计时器时间：
        time: 30 * 60 * 60 * 1000,
        //轮播图列表：
        bannerList:[]
      }
    },
   async created(){
     let res= await this.$http.getHomeApi();
    //  获取首页list列表数据：
     this.listText=res.data.data.list[2].icon_list;
     this.bannerList=res.data.data.list[0].icon_list;
     console.log(res.data.data)
     console.log(this.bannerList)
   },
   methods:{
      shoparr(){
        //获取购物车需要展示的信息；o
        
      }
   }
}
</script>

<style lang="scss"> 
  .top{
    margin:0 auto;
    width:7.5rem;
    height:8rem;
    background:url('../../assets/3.jpg');
    background-size: 100% 100%;
    .middle{
      height:3.5rem;
      width:7rem;
      .my-swipe{
        width:7rem;
        margin-left:.25rem;
        margin-top:.5rem;
        height:3rem;
        border-bottom-left-radius: .45rem;
        border-bottom-right-radius: .45rem;
         .van-swipe-item {
          color: #fff;
          font-size: 20px;
          line-height: 150px;
          text-align: center;
          background-color: #39a9ed;
            img{
            width:100%;
            height:100%;
          }
        } 
      }
    }
    .top1{
      height:1rem;
      margin:0 auto;
      display: flex;
      justify-content: space-between;
        .left{
        width:3.4rem;
        height:.8rem;
        line-height: .8rem;
        padding:0 .2rem;
        color:#fff;
        border-radius: .8rem;
        font-size: .3rem;
        background: rgba(0,0,0,.6);
        margin-top:.2rem;
      }
      i{
        margin-right:.1rem;
      }
      .right{
        margin-top:.2rem;
        input{
          display: block;
          width:2.3rem;
          height:.8rem;
          border:0 none;
          font-size: .3rem;
          padding:0 .6rem;
          color:#888;
          background: #e8e8e8;
          border-radius: .5rem;
        }
        i{
          font-size: .4rem;
          position: absolute;
          top:.4rem;
          left:4.2rem;
          color:#888;
        }
      }
    }
  }
  .home_list{
    display: flex;
    flex-wrap: wrap;  
    width:7.5rem;
    margin:0 auto;
    height:3.2rem;
    li{
      width:1rem;
      height:.1rem;
      margin-left:.4rem;
    }
    img{
      border-radius: 50%;
      width:.6rem;
      height: .6rem;
      display: block;
      margin:0 auto;
    }
    p{
      font-size:.2rem;
      text-align: center;
    }
  }
  .vip{
    width:6.5rem;
    height:.75rem;
    margin:0 auto;
    background: #42b95f;
    border-radius: .1rem;
    padding-left:.2rem;
    padding-right:.2rem;
    margin:0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color:#fff;
    span{
      font-size:.25rem;  
    }
    img{
      width:.7rem;
      height:.6rem;
      border-radius: .2rem;
    }
  }
  .timeShop{
    height:5.5rem;
    .shop-top{
        width:7.5rem;
        margin:0 auto;
        display: flex;
        height:1.5rem;
        justify-content: space-between;
        align-items: center;
        .acive-icon{
          display: block;
          width:0.07em;
          height: .45rem;
          background:#42b95f;
          margin-top:0.1rem;
          margin-left:.45rem;
        }
        h6{
          width:2rem;
          font-size:.45rem;
        }
        .more{
          font-size: .3rem;
          color:#42b95f;
          margin-right:.3rem;
        }
        .timeout{
          width:2rem;
          margin-right:1.8rem;
        }
        .colon {
          display: inline-block;
          margin: 0 4px;
          color: #ee0a24;
        }
        .block {
          display: inline-block;
          width: 22px;
          color: #fff;
          font-size: 12px;
          text-align: center;
          background-color: #000;
        }
      }
      .shop-text{
        height:5rem;
      }
  }
  .listShop{
    height:7rem;
    .van-tabs__line{
      background-color: #42b95f;
    }
  }

</style>